import { dangrous_style, target_style } from "utils/constants/globalconstant";
import { ActionBase, ActionBaseOfCreep } from "../ActionBase";

 

/**
 * 放置site Action
 */
export class ActionVisualTeam  extends ActionBase<IActionCMD<"visualTeam">>
{
    public execute(action: IActionCMD<"visualTeam">): ActionCode 
    {
        const entity = action.arg.entity;
        const memory = entity.getNodeMemory();
       
        const visualgoal = (goal:IRoomPosition)=>
        {
            const goalroom = Game.rooms[goal.roomName];
            if(goalroom)
            {
                const leader = entity.getAnchor();
                goalroom.visual.line(leader.x,leader.y,goal.x,goal.y,target_style)
            }
        }
        if(memory.goal )
        {
            if(memory.goal.pos)
            {
                visualgoal(memory.goal.pos)
            }
            
        }
        else
        {
            if (memory.targets.length>0)
            {
                visualgoal(memory.targets[0].attackTarget)
            }
            
        }
        const attacks = entity.getAttacker();
        const heals= entity.getHealer();
        
        if(attacks.length && heals.length  )
        {
            const room = attacks[0].room;
            room.visual.circle(attacks[0].pos,dangrous_style);
           
            room.visual.line(heals[0].pos.x,heals[0].pos.y,attacks[0].pos.x,attacks[0].pos.y,target_style)
        }
        
        return 0;
    }
}